<template>
	<view class="container">
		<view class="tip">
			<text>请填写信息</text>
		</view>

		<view class="list">
			<view class="list-item">
				<text>手机号</text>
				<input type="text" value="" v-model="mobile" placeholder="请输入" />
			</view>
			<view class="list-item">
				<text>密码</text>
				<input type="password" value="" v-model="password" placeholder="请输入" />
			</view>
		</view>

		<view class="btn">
			<button type="default" @click="submit">确认</button>
		</view>


	</view>
</template>

<script>
	import {
        addOperate,
	} from '../../../api/api.js'
	export default {
		data() {
			return {
				mobile: '',
				password: '',
			}
		},
		onLoad() {
		},
		methods: {
			submit() {
				let reg = /^1[3|4|5|7|8|9][0-9]{9}$/;
				if (!reg.test(this.mobile)) {
					uni.showToast({
						icon: 'none',
						title: '请输入正确的手机号'
					})
					return
				}
				if (!this.password) {
					uni.showToast({
						icon: 'none',
						title: '请输入密码'
					})
					return
				}
				addOperate({
					mobile:this.mobile,
					password:this.password
				}).then(res=>{
					if(res.code == 1){
						let pages = getCurrentPages();
						let nowPage = pages[pages.length - 1];
						let prevPage = pages[pages.length - 2];
						prevPage.page = 1;
						prevPage.loadData('refresh');
						uni.navigateBack({
							delta: 1,
						})
						
						
					}
				})
				
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		width: 100%;
		height: 100%;
		background-color: #f6f6f6;
	}

	.tip {
		width: calc(100% - 60upx);
		height: 80upx;
		line-height: 80upx;
		padding: 0 30upx;
		font-size: 28upx;
		color: #666666;
	}

	.list {
		width: calc(100% - 60upx);
		padding: 0 30upx;
		background-color: #FFFFFF;

		.list-item {
			width: 100%;
			height: 80upx;
			line-height: 80upx;
			padding: 10upx 0;
			display: flex;
			justify-content: space-between;
			border-bottom: 1upx solid #ECECEC;

			input {
				height: 100%;
				min-width: 200upx;
				text-align: right;
			}
		}
	}

	.btn {
		width: calc(100% - 60upx);
		margin: 40upx auto;
		height: 90upx;

		button {
			width: 100%;
			height: 100%;
			height: 90upx;
			border-radius: 45upx;
			background-color: #3eb9fe;
			color: #FFFFFF;
		}
	}
</style>
